package de.mp3player.gui;

import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.*;

import de.mp3player.gui.ToolbarPanel;
import de.mp3player.gui.dialogs.CreatePlaylistFrame;
import de.mp3player.gui.dialogs.Preferences;
import de.mp3player.internalization.*;

public class Menupanel extends JPanel{
	
	private JMenuBar menubar;
	
	private JMenu menuFile;
	private JMenu menuEdit;
	private JMenu menuExtra;
	private JMenu menuSim;
	
	private JMenuItem neu;
	private JMenuItem open;
	private JMenuItem save;
	private JMenuItem exit;
	
	private JMenuItem undo;
	private JMenuItem redo;
	private JMenuItem pref;
	private JMenuItem createPlaylist;
	private JMenuItem internetradio;
	private JMenuItem podcast;
	
	private JMenuItem help;
	private JMenuItem update;
	private JMenuItem about;
	
	private JMenuItem simStart;
	private JMenuItem simStop;
	
	private ToolbarPanel toolbar;
	
	public Menupanel(){
		this.setLayout(new BorderLayout());
		
		this.menubar = new JMenuBar();
		this.menuFile = new JMenu(Messages.getString("Menupanel.0")); //$NON-NLS-1$
		this.menuEdit = new JMenu(Messages.getString("Menupanel.1")); //$NON-NLS-1$
		this.menuExtra = new JMenu(Messages.getString("Menupanel.2")); //$NON-NLS-1$
		this.neu = new JMenuItem(Messages.getString("Menupanel.3")); //$NON-NLS-1$
		this.open = new JMenuItem(Messages.getString("Menupanel.4")); //$NON-NLS-1$
		this.save = new JMenuItem(Messages.getString("Menupanel.5")); //$NON-NLS-1$
		this.exit = new JMenuItem(Messages.getString("Menupanel.6")); //$NON-NLS-1$
		this.undo = new JMenuItem("Undo");
		this.redo = new JMenuItem("Redo");
		this.pref = new JMenuItem(Messages.getString("Menupanel.7")); //$NON-NLS-1$
		this.createPlaylist = new JMenuItem(Messages.getString("Menupanel.8")); //$NON-NLS-1$
		this.internetradio = new JMenuItem(Messages.getString("Menupanel.9")); //$NON-NLS-1$
		this.podcast = new JMenuItem(Messages.getString("Menupanel.10")); //$NON-NLS-1$
		this.help = new JMenuItem(Messages.getString("Menupanel.11")); //$NON-NLS-1$
		this.update = new JMenuItem(Messages.getString("Menupanel.12")); //$NON-NLS-1$
		this.about = new JMenuItem(Messages.getString("Menupanel.13")); //$NON-NLS-1$
		this.toolbar = new ToolbarPanel();
		initAction();
		buildPanelMn();
	}

	private void initAction() {
		//TODO ActionListener für MenuButtons implementieren
		this.createPlaylist.addActionListener(new ActionListener(){
			@Override
			public void actionPerformed(ActionEvent arg0) {
				CreatePlaylistFrame pf = new CreatePlaylistFrame();
			}
		});
		this.pref.addActionListener(new ActionListener(){
			@Override
			public void actionPerformed(ActionEvent arg0) {
				Preferences prefDlg = new Preferences();
			}
		});
		this.open.addActionListener(new ActionListener(){
			@Override
			public void actionPerformed(ActionEvent arg0) {
				
			}
		});
	}

	private void buildPanelMn(){
		this.menuFile.add(neu);
		this.menuFile.add(new JSeparator());
		this.menuFile.add(open);
		this.menuFile.add(save);
		this.menuFile.add(new JSeparator());
		this.menuFile.add(exit);
		this.menuEdit.add(undo);
		this.menuEdit.add(redo);
		this.menuEdit.add(new JSeparator());
		this.menuEdit.add(pref);
		this.menuEdit.add(new JSeparator());
		this.menuEdit.add(createPlaylist);
		this.menuEdit.add(internetradio);
		this.menuEdit.add(podcast);
		this.menuExtra.add(help);
		this.menuExtra.add(update);
		this.menuExtra.add(about);
		this.menubar.add(menuFile);
		this.menubar.add(menuEdit);
		this.menubar.add(menuExtra);
		this.add(menubar,BorderLayout.NORTH);
		this.add(toolbar,BorderLayout.SOUTH);
	}
	

}
